// ignore_for_file: unused_local_variable

import 'package:flutter/cupertino.dart';
import 'package:flutter/material.dart';
import 'package:flutter/rendering.dart';
import 'package:flutter_app/main02.dart';
import 'res/listData.dart';

main() {
  runApp(MyApp());
}

class MyApp extends StatelessWidget {
  @override
  Widget build(BuildContext context) {
    return MaterialApp(
      home: Scaffold(
        appBar: AppBar(
          title: Text('Flutter Demo'),
        ),
        body: LayoutDemo(),
      ),
    );
  }
}

class LayoutDemo extends StatelessWidget {
  Widget _getListData(context, index) {
    return Card(
      margin: EdgeInsets.all(10),
      child: Column(
        children: [
          AspectRatio(
            aspectRatio: 39 / 16,
            child: Image.network(
              listData[index]['imageUrl'],
              fit: BoxFit.cover,
            ),
          ),
          ListTile(
            leading: CircleAvatar(
              backgroundImage: NetworkImage(
                "https://nimg.ws.126.net/?url=http%3A%2F%2Fdingyue.ws.126.net%2FnJmjx6MxgPEsfXSy6vLzqoanX5pAUVVgVVU2Avr07ABws1546655747784.jpeg&thumbnail=650x2147483647&quality=80&type=jpg",
              ),
            ),
            title: Text(listData[index]['author']),
            subtitle: Text(listData[index]['title']),
          ),
        ],
      ),
    );
  }

  @override
  Widget build(BuildContext context) {
    return ListView.builder(
      itemCount: listData.length,
      itemBuilder: this._getListData,
    );
  }
}
